using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;

public static class TerrainGUIUtility
{
    
}
public class OverriderFloat : OverriderValue<float>
    {
        public OverriderFloat(float v) : base(v)
        {
        }

        protected override float DrawValue()
        {
            return EditorGUILayout.FloatField(value);
        }
    }

    public class OverriderBool : OverriderValue<bool>
    {
        public OverriderBool(bool v) : base(v)
        {
        }

        protected override bool DrawValue()
        {
            return EditorGUILayout.Toggle(value);
        }
    }

    public class OverriderShadowCast : OverriderValue<UnityEngine.Rendering.ShadowCastingMode>
    {
        public OverriderShadowCast(ShadowCastingMode v) : base(v)
        {
            value = v;
        }

        protected override ShadowCastingMode DrawValue()
        {
            return (ShadowCastingMode)EditorGUILayout.EnumPopup(value);
        }
    }

    public class OverProbeSetting : OverriderValue<ReflectionProbeUsage>
    {
        public OverProbeSetting(ReflectionProbeUsage v) : base(v)
        {
        }

        protected override ReflectionProbeUsage DrawValue()
        {
            return (ReflectionProbeUsage) EditorGUILayout.EnumPopup(value);
        }
    }

    
    public  class OverriderFloatRange: OverriderValue<float>
    {

        public float max;
        public float min;
        
        public OverriderFloatRange(float v,float min,float max) : base(v)
        {
            this.max = max;
            this.min = min;
            this.value = v;
        }

        protected override float DrawValue()
        {
            return EditorGUILayout.Slider(value, min, max);
        }
    }

    public class OverriderInt : OverriderValue<int>
    {
        public OverriderInt(int v) : base(v)
        {
            this.value = v;

        }

        protected override int DrawValue()
        {
            return EditorGUILayout.IntField(value);
        }
    }

    public class OverriderIntRange : OverriderValue<int>
    {
        public int min;
        public int max;
        public OverriderIntRange(int v,int min ,int max) : base(v)
        {
            this.min = min;
            this.max = max;
            this.value = v;
        }

        protected override int DrawValue()
        {

            return EditorGUILayout.IntSlider(value, min, max,GUILayout.Width(100));

        }
    }


    public  abstract class OverriderValue<T>
    {

        public T value;
        public bool overrider;

        protected abstract T DrawValue();
        
        public virtual void DrawEditorIns(string str)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
            this.overrider = EditorGUILayout.Toggle(this.overrider,GUILayout.Width(15));
            EditorGUILayout.LabelField(str,GUILayout.Width(150));
            this.value = DrawValue();
            EditorGUILayout.EndHorizontal();
        
        }

        public OverriderValue(T v)
        {
            v = value;
        }

        
    }